﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

using ZhimeiSoft.CharmManager.DOL;
using ZhimeiSoft.CharmManager.Server.Factory;
using ZhimeiSoft.CharmManager.Server.BLL.Interface;
using ZhimeiSoft.CharmManager.Interface;

namespace ZhimeiSoft.CharmManager.Server.Proxy.Impl
{
    public class WSBusinessServerProxyImpl : IBusinessService
    {
        private IEmployeeBLL employeeBLL;
        private IEmployeeVacationBLL employeeVacationBLL;
        private ISalonInfoBLL salonInfoBLL;
        private ICustomerBLL customerBLL;
        private IScheduleBLL scheduleBLL;

        public WSBusinessServerProxyImpl()
        {
            employeeBLL = BaseBLLFactory.CreateEmployeeBLL();
            employeeVacationBLL = BaseBLLFactory.CreateEmployeeVacationBLL();
            salonInfoBLL = BaseBLLFactory.CreateSalonInfoBLL();
            customerBLL = BaseBLLFactory.CreateCustomerBLL();
            scheduleBLL = BaseBLLFactory.CreateScheuleBLL();
        }

        #region 员工管理

        /// <summary>
        /// 新增员工信息
        /// </summary>
        /// <param name="employee">员工信息实体类</param>
        /// <returns>员工ID</returns>
        public bool InsertEmployee(EmployeeEntity employee, out string error)
        {
            error = string.Empty;
            try
            {
                employeeBLL.InsertEmployee(employee);
            }
            catch (Exception ex)
            {
                error = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            return true;
        }

        /// <summary>
        /// 更新员工信息
        /// </summary>
        /// <param name="employee">员工信息实体类</param>
        public bool UpdateEmployee(EmployeeEntity employee, out string error)
        {
            error = string.Empty;
            try
            {
                employeeBLL.UpdateEmployee(employee);
            }
            catch (Exception ex)
            {
                error = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            return true;
        }

        /// <summary>
        /// 删除员工信息
        /// </summary>
        /// <param name="employeeid">员工ID</param>
        public bool DeleteEmployee(int employeeid, out string error)
        {
            error = string.Empty;
            try
            {
                employeeBLL.DeleteEmployee(employeeid);
            }
            catch (Exception ex)
            {
                error = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            return true;
        }

        /// <summary>
        /// 根据员工状态查询员工信息
        /// </summary>
        /// <param name="state">状态F0E 在职、 F0Q 离职、 F0S停岗</param>
        /// <param name="dsEmployeeData">返回员工数据</param>
        /// <param name="error">错误信息</param>
        /// <returns>返回是否成功</returns>
        public bool QueryEmployeeState(string state, out System.Data.DataSet dsEmployeeData, out string error)
        {
            error = string.Empty;
            dsEmployeeData = null;
            try
            {
                dsEmployeeData = employeeBLL.QueryEmployeeState(state);
            }
            catch (Exception ex)
            {
                error = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            return true;
        }


        #endregion


        #region 员工休假管理


        public bool InsertEmployeeVacation(DBEntityEmoloyeeVacation employeeVacation, out string error)
        {
            error = string.Empty;
            try
            {
                employeeVacationBLL.InsertEmployeeVacation(employeeVacation);
            }
            catch (Exception ex)
            {
                error = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            return true;
        }

        public bool DelEmployeeVacation(DBEntityEmoloyeeVacation employeeVacation, out string error)
        {
            error = string.Empty;
            try
            {
                employeeVacationBLL.DelEmployeeVacation(employeeVacation);
            }
            catch (Exception ex)
            {
                error = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            return true;
        }

        public bool UpdateEmployeeVacation(DBEntityEmoloyeeVacation employeeVacation_old, DBEntityEmoloyeeVacation employeeVacation_new, out string error)
        {
            error = string.Empty;
            try
            {
                employeeVacationBLL.UpdateEmployeeVacation(employeeVacation_old, employeeVacation_new);
            }
            catch (Exception ex)
            {
                error = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            return true;
        }

        public bool QueryEmployeeVacationDateTime(string startDate, string endDate, out System.Data.DataSet dsEmployeeVacation, out string error)
        {
            error = string.Empty;
            dsEmployeeVacation = null;
            try
            {
               dsEmployeeVacation = employeeVacationBLL.QueryEmployeeVacationDateTime(startDate, endDate);
            }
            catch (Exception ex)
            {
                error = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            return true;
        }

        public bool QueryEmployeeVacationEmployeeID(int employeeID, string startDate, string endDate, out System.Data.DataSet dsEmployeeVacation, out string error)
        {
            error = string.Empty;
            dsEmployeeVacation = null;
            try
            {
                dsEmployeeVacation = employeeVacationBLL.QueryEmployeeVacationEmployeeID(employeeID, startDate, endDate);
            }
            catch (Exception ex)
            {
                error = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            return true;
        }

        #endregion


        #region 店铺信息管理

        public bool QuerySalonInfo(out System.Data.DataSet dsSalonInfo, out string error)
        {
            error = string.Empty;
            dsSalonInfo = null;
            try
            {
                dsSalonInfo = salonInfoBLL.getSalonInfo();
            }
            catch (Exception ex)
            {
                error = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            return true;
        }

        #endregion


        #region 客户信息管理

        /// <summary>
        /// 添加客户信息
        /// </summary>
        /// <param name="customer"></param>
        /// <returns></returns>
        public bool InsertCustomer(DBEntityCustomInfo customerInfo, out string error)
        {
            error = string.Empty;
            try
            {
                customerBLL.InsertCustomer(customerInfo);
            }
            catch (Exception ex)
            {
                error = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            return true;
        }

        /// <summary>
        /// 修改客户信息
        /// </summary>
        /// <param name="customer"></param>
        public bool UpdateCustomer(DBEntityCustomInfo customerInfo, out string error)
        {
            error = string.Empty;
            try
            {
                customerBLL.UpdateCustomer(customerInfo);
            }
            catch (Exception ex)
            {
                error = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            return true;
        }

        /// <summary>
        /// 删除客户信息
        /// </summary>
        /// <param name="customerID"></param>
        public bool DeleteCustomer(int customerID, out string error)
        {
            error = string.Empty;
            try
            {
                customerBLL.DeleteCustomer(customerID);
            }
            catch (Exception ex)
            {
                error = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            return true;
        }
        /// <summary>
        /// 根据用户状态查询用户信息
        /// </summary>
        /// <param name="stateStr">用户状态</param>
        /// <param name="dsCustomInfo">返回数据</param>
        /// <param name="error">错误信息</param>
        /// <returns></returns>
        public bool QueryCustomState(string stateStr, out System.Data.DataSet dsCustomInfo, out string error)
        {
            dsCustomInfo = null;
            error = string.Empty;
            try
            {
                dsCustomInfo = customerBLL.QueryCustomState(stateStr);
            }
            catch (Exception ex)
            {
                error = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            return true;
        }
        /// <summary>
        /// 根据用户ID获取用户信息
        /// </summary>
        /// <param name="customID">用户ID</param>
        /// <param name="dsCustomInfo">返回用户数据</param>
        /// <param name="error">错误信息</param>
        /// <returns>是否成功</returns>
        public bool QueryCustomID(int customID, out DataSet dsCustomInfo, out string error)
        {
            dsCustomInfo = null;
            error = string.Empty;
            try
            {
                dsCustomInfo = customerBLL.QueryCustomID(customID);
            }
            catch (Exception ex)
            {
                error = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            return true;
        }
        #endregion


        #region 预约管理


        public bool InsertSchedule(DBEntitySchedule scheduleInfo, out string error)
        {
            error = string.Empty;
            try
            {
                scheduleBLL.InsertSchedule(scheduleInfo);
            }
            catch (Exception ex)
            {
                error = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            return true;
        }

        public bool DeleteSchedule(DBEntitySchedule scheduleInfo, out string error)
        {
            error = string.Empty;
            try
            {
                scheduleBLL.DeleteSchedule(scheduleInfo);
            }
            catch (Exception ex)
            {
                error = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            return true;
        }

        public bool UpdateSchedule(DBEntitySchedule scheduleInfo, out string error)
        {
            error = string.Empty;
            try
            {
                scheduleBLL.UpdateSchedule(scheduleInfo);
            }
            catch (Exception ex)
            {
                error = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            return true;
        }

        public bool QueryScheduleState(string scheduleState, out System.Data.DataSet dsSchedule, out string error)
        {
            error = string.Empty;
            dsSchedule = null;
            try
            {
                dsSchedule = scheduleBLL.QueryScheduleState(scheduleState);
            }
            catch (Exception ex)
            {
                error = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            return true;
        }

        #endregion

    }
}
